﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;

namespace HYBatchPrinter.Utils
{
	public static class PrintSettingManager
	{
		public static List<string> GetCurDocAllUsefulPrintSetting(Document doc)
		{
			List<string> list = new List<string>();
			if (doc != null)
			{
				foreach (ElementId elementId in doc.GetPrintSettingIds())
				{
					Element element = doc.GetElement(elementId);
					PrintSetting printSetting = element as PrintSetting;
					if (printSetting != null)
					{
						try
						{
							if (printSetting.PrintParameters.PaperSize != null)
							{
								list.Add(element.Name);
							}
						}
						catch (Exception)
						{
						}
					}
				}
			}
			return list;
		}

		public static bool IsPrintSettingValid(string sSettingName, Document doc)
		{
			bool result = false;
			if (PrintSettingManager.GetCurDocAllUsefulPrintSetting(doc).Contains(sSettingName))
			{
				result = true;
			}
			return result;
		}
	}
}
